package com.sojson.project.monitor.server.entity.bo;

import com.sojson.base.impl.Base;
import com.sojson.util.ArithUtil;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * 內存相关信息
 * 
 * @author liu
 * @date 2021-11-10
 */
@ApiModel("內存相关信息")
public class Mem extends Base {

    /**  */
    private static final long serialVersionUID = 1L;
    @ApiModelProperty("内存总量")
    private double total;
    @ApiModelProperty("已用内存")
    private double used;
    @ApiModelProperty("剩余内存")
    private double free;

    /** 获取 内存总量 */
    public double getTotal() {
        return ArithUtil.div(total, (1024 * 1024 * 1024), 2);
    }

    /** 设置 内存总量 */
    public void setTotal(long total) {
        this.total = total;
    }

    /** 获取 已用内存 */
    public double getUsed() {
        return ArithUtil.div(used, (1024 * 1024 * 1024), 2);
    }

    /** 设置 已用内存 */
    public void setUsed(long used) {
        this.used = used;
    }

    /** 获取 剩余内存 */
    public double getFree() {
        return ArithUtil.div(free, (1024 * 1024 * 1024), 2);
    }

    /** 设置 剩余内存 */
    public void setFree(long free) {
        this.free = free;
    }

    /** 获取 内存使用率 */
    public double getUsage() {
        return ArithUtil.mul(ArithUtil.div(used, total, 4), 100);
    }

}